public class ThreadDemo16 {
    private  static  Object  locker1=new Object();
    private  static  Object  locker2=new Object();
    private  static  Object  locker3=new Object();
    public static void main(String[] args) throws InterruptedException {
/*
有三个线程，线程名称分别为：a，b，c。
每个线程打印自己的名称。
需要让他们同时启动，并按 c，b，a的顺序打印
 */
        Thread c=new Thread( ()->
        {

            try {
                    synchronized (locker3)
                    {
                        locker3.wait();
                    }

                    System.out.print("c");
                    synchronized (locker2)
                    {
                        locker2.notify();
                    }

            } catch (InterruptedException e)
            {
                e.printStackTrace();
            }

        });
        Thread b=new Thread( ()-> {
            try {

                    synchronized (locker2)
                    {
                        locker2.wait();
                    }

                    System.out.print("b");
                    synchronized (locker1)
                    {
                        locker1.notify();
                    }

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        Thread a=new Thread( ()-> {
            try {

                    synchronized (locker1)
                    {
                        locker1.wait();
                    }

                    System.out.println("c");

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        a.start();
        b.start();
        c.start();

        Thread.sleep(1000);
        synchronized (locker3){
            locker3.notify();
        }
    }
}
